<?php namespace web\home\controller;
class Common{
	public function __construct(){
		//分配头部数据顶级分类
		$topcate=Db::table('category')->where('pid',0)->get();
//		p($topcate);die;
		View::with('topcate',$topcate);
		//分配右边的分类数据
		$rightcate=Db::table('category')->orderBy('cid','ASC')->get();
//		p($rightcate);die;
		//需要将当前分类中有几篇文章查询出来压入到分类数据中
		foreach ($rightcate as $k => $v) {
			//压入有几篇文章的数据
			$rightcate[$k]['total']=Db::table('article')->where('category_cid',$v['cid'])->count();
			
		}
//		p($rightcate);die;
		View::with('rightcate',$rightcate);
		//2右侧的所有标签数据
		$rightTag=Db::table('tag')->get();
		View::with('rightTag',$rightTag);
//		p($rightTag);die;
		//3底部有情链接
		$dowLink=Db::table('link')->get();
//		p($dowLink);die;

  		View::with('dowLink',$dowLink);
	    //底部最新文章
	    $newarc=Db::table('article')->where('is_recycle',0)->orderBy('sendtime','DESC')->limit(2)->get();
//	    p($arcdata);die;
        View::with('newarc',$newarc);
	
	
	}
	
}
?>